<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="renderer" content="webkit"> 
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> 
<meta name="format-detection" content="telephone=no" /> 
<link rel="shortcut icon" href="images/logo.ico" />
<title>闪度生活</title>
<meta name="keywords" content=" " />
<meta name="description" content=" " />


<link rel="stylesheet" type="text/css" href="css/common.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/font-awesome.css">
<link rel="stylesheet" type="text/css" href="css/swiper-3.4.1.min.css">
<link href="css/mui.min.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="css/style.css">

<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/bootstrap.js"></script>
<script src="js/jquery-ui.min.js"></script>
<script src="js/easing.js"></script>
<script src="js/swiper-3.4.1.min.js"></script>
<script src="js/index.js"></script>
<script src="js/main.js"></script>
<script src="js/mui.min.js"></script> 
<script src="js/mui.indexedlist.js"></script>


<script src="./js/vue.js"></script>
<script src="./js/axios.min.js"></script>
<script src="./js/axios-config.js"></script>
<script src="./js/js.cookie.js"></script>
<script src="./js/utils.js"></script>

</head>

<body class="body_bg2">

<div id="app" v-cloak>

<!--  / header  -->
<div class="header_longevity">
        <div class="header_map_longevity">   
            <img src="images/jiantou.png" alt="">
            <span>返回</span>
        </div>
        <div class="logo_longevity">地址管理</div>
        <a href="addAddress.html" @click="clone_addressid"><div class="header_shop_longevity">新增地址</div></a>   
</div>
<!--  / header  -->


<div class="mySet">
    <div :class="index!=0 ? 'myAddress1 myAddress2' : 'myAddress1'" v-for="(ress,index) in address_list" class="mui-table-view-cell mui-transitioning" :key="ress.addressid" @click="addressList(ress)">
    	<div class="mui-slider-right mui-disabled">
			<a class="mui-btn mui-btn-red" @click="delete_ress(ress.addressid)">删除</a>
		</div>
		<div class="mui-slider-handle">
	        <div class="clearfix myAddress1-text1">
	            <span class="fl">{{ress.consignee}}</span>
	            <span class="fr">{{ress.telephone}}</span>
	        </div>
	        <div class="myAddress1-text2">
	            <span>{{ress.province}}{{ress.city}}{{ress.district}}{{ress.address}}</span>
	        </div>
	        <div class="clearfix myAddress1-text3">
	            <div class="fl">
	                <img v-if="ress.isdefault == 0" src="images/dui.png" alt="">
	                <img v-else src="images/dui1.png" alt="">
	                <span @click="setIsdefaultset(ress.addressid)">设为默认</span>
	            </div>
	            <a href="addAddress.html" @click="jump(ress.addressid)">
	            <div class="fr">
	                <img src="images/bianji.png" alt="">
	                <span>编辑</span>
	            </div>
	            </a>
	        </div>
        </div>
    </div>
    <!--<div class="myAddress1 myAddress2">
            <div class="clearfix myAddress1-text1">
                <span class="fl">秋日</span>
                <span class="fr">15852526548</span>
            </div>
            <div class="myAddress1-text2">
                <span>浙江省杭州市</span>
            </div>
            <div class="clearfix myAddress1-text3">
                <div class="fl">
                    <img src="images/dui.png" alt="">
                    <span>设为默认</span>
                </div>
                <a href="addAddress.html">
                <div class="fr">
                    <img src="images/bianji.png" alt="">
                    <span>编辑</span>
                </div>
                </a>
            </div>
            
    </div>
    <div class="myAddress1 myAddress2">
            <div class="clearfix myAddress1-text1">
                <span class="fl">秋日</span>
                <span class="fr">15852526548</span>
            </div>
            <div class="myAddress1-text2">
                <span>浙江省杭州市</span>
            </div>
            <div class="clearfix myAddress1-text3">
                <div class="fl">
                    <img src="images/dui.png" alt="">
                    <span>设为默认</span>
                </div>
                <a href="addAddress.html">
                <div class="fr">
                    <img src="images/bianji.png" alt="">
                    <span>编辑</span>
                </div>
                </a>
            </div>
            
    </div>-->
</div>

</div>
</body>
<script>
$(window).ready(function(){

var vm = new Vue({
		el:"#app",
		data() {
            return {
                userId: (() => {
                        
                    })(),
                address_list:''
            }
		},
    created: function () {
		var $this = this;
    	$this.getAddress_list();
    },
    mounted:function(){
    	
    },
    methods:{
    	
    	//我的收货地址
    	getAddress_list:function(){
    		var $this = this;
    		
    		const data = {
    		}
    		
    		Axios.post(window.Url.address_list, data).then((res) => {
    			
    			if(res.result == 1){
    				$this.address_list = res.info.address;
    				
    			}
    			else{
    				alert('我的收货地址'+res.info)
    			}
    			
        }).catch((err) => {
          console.log('我的收货地址'+err)
        })
        
    	},
    	//设置默认地址
    	setIsdefaultset:function(addressid){
    		var $this = this;
    		
    		const data = {
				addressid:addressid
    		}
    		
    		Axios.post(window.Url.isdefaultset, data).then((res) => {
    			
    			if(res.result == 1){
    				alert(res.info);
    				location.reload();
    			}
    			else{
    				alert('设置默认地址'+res.info)
    			}
    			
        }).catch((err) => {
          console.log('设置默认地址'+err)
        })
        
    	},
    	//删除地址
    	delete_ress:function(addressid){
    		var $this = this;
    		
    		const data = {
				addressid:addressid
    		}
    		
    		Axios.post(window.Url.delete_ress, data).then((res) => {
    			if(res.result == 1){
    				alert(res.info);
    				location.reload();
    			}
    			else{
    				alert('删除地址'+res.info)
    			}
    			
        }).catch((err) => {
          console.log('删除地址'+err)
        })
        
    	},
    	//跳转详情页(编辑地址)
    	jump:function(type_id){
    		setCookie('addressid',type_id);
    	},

        //跳转新增地址
    	clone_addressid:function(){
    		setCookie('addressid','');
    	},

        //判断是从拼团确认下单页面进入的还是服务订单进入
        addressList:function(detail){
            var type=getCookie("what");
            // console.log(type);
            if(type == 1){
                sessionStorage.setItem('addressDetail', JSON.stringify(detail));
                // console.log(1);
                window.location.href="service_inner1.html";
            }else if(type == 2){
                sessionStorage.setItem('addressDetail', JSON.stringify(detail));
                // console.log(2);
                window.location.href="order_sure.html";
            }
        }

	}
})

$('.banner').height($(window).width()*400/750);

var mySwiper_banner = new Swiper ('.swiper-container-banner', {
    loop: true,
    pagination: '.swiper-pagination-banner',
	autoplay : 5000,
	autoplayDisableOnInteraction : false,
})
$('.header_map_longevity').click(function(){
    history.go(-1);
});
$('.mySet-address').click(function(){
    
})


  
})  
</script>
</html>
